package com.ruoyi.web.controller.swimming;

import java.util.List;

import com.ruoyi.swimming.domian.SwimmingTicketTimes;
import com.ruoyi.swimming.service.ISwimmingTicketTimesService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 泳票次数Controller
 * 
 * @author ruoyi
 * @date 2021-07-17
 */
@RestController
@RequestMapping("/system/times")
public class SwimmingTicketTimesController extends BaseController
{
    @Autowired
    private ISwimmingTicketTimesService swimmingTicketTimesService;

    /**
     * 查询泳票次数列表
     */
    @PreAuthorize("@ss.hasPermi('system:times:list')")
    @GetMapping("/list")
    public TableDataInfo list(SwimmingTicketTimes swimmingTicketTimes)
    {
        startPage();
        List<SwimmingTicketTimes> list = swimmingTicketTimesService.selectSwimmingTicketTimesList(swimmingTicketTimes);
        return getDataTable(list);
    }

    /**
     * 导出泳票次数列表
     */
    @PreAuthorize("@ss.hasPermi('system:times:export')")
    @Log(title = "泳票次数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SwimmingTicketTimes swimmingTicketTimes)
    {
        List<SwimmingTicketTimes> list = swimmingTicketTimesService.selectSwimmingTicketTimesList(swimmingTicketTimes);
        ExcelUtil<SwimmingTicketTimes> util = new ExcelUtil<SwimmingTicketTimes>(SwimmingTicketTimes.class);
        return util.exportExcel(list, "泳票次数数据");
    }

    /**
     * 获取泳票次数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:times:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(swimmingTicketTimesService.selectSwimmingTicketTimesById(id));
    }

    /**
     * 新增泳票次数
     */
    @PreAuthorize("@ss.hasPermi('system:times:add')")
    @Log(title = "泳票次数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SwimmingTicketTimes swimmingTicketTimes)
    {
        return toAjax(swimmingTicketTimesService.insertSwimmingTicketTimes(swimmingTicketTimes));
    }

    /**
     * 修改泳票次数
     */
    @PreAuthorize("@ss.hasPermi('system:times:edit')")
    @Log(title = "泳票次数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SwimmingTicketTimes swimmingTicketTimes)
    {
        return toAjax(swimmingTicketTimesService.updateSwimmingTicketTimes(swimmingTicketTimes));
    }

    /**
     * 删除泳票次数
     */
    @PreAuthorize("@ss.hasPermi('system:times:remove')")
    @Log(title = "泳票次数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(swimmingTicketTimesService.deleteSwimmingTicketTimesByIds(ids));
    }
}
